<template>
  <div class="app-container">
    <el-dialog :title="'拆单'+'（'+form.saleOrderNo+'）'" :visible.sync="dialogVisible" width="30%">
      <el-form ref="form" :model="form" v-loading="loading">
        <el-form-item label="包裹序号" prop="bagNum" required>
          <el-input type="number" v-model="form.bagNum" :min="0" placeholder="请输入"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible=false">取 消</el-button>
        <el-button type="primary" @click="dialogOk" v-loading="loading">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>


import {splitSendGood} from "../../../../api/expressMng";

export default {
  data() {
    return {
      flag: 0,
      loading: false,
      dialogVisible: false,
      form: {
        bagNum: ''
      }
    }
  },
  methods: {
    show(form) {
      this.dialogVisible = true
      this.resetForm('form')
      this.form.id = form.id
      this.form.saleOrderNo = form.saleOrderNo
    },
    dialogOk() {
      this.$refs.form.validate(e => {
        if (e) {
          this.loading = true
          splitSendGood(this.form).then(res => {
            this.dialogVisible = false
            this.$emit('ok')
            this.$message.success('拆单成功')
          }).finally(e => {
            this.loading = false
          })
        }
      })
    },
  }
}
</script>
